package name.marz.to.go.ahg.mhbk.executer;

import java.net.URI;
import java.util.ArrayList;
import java.util.List;

import name.marz.to.go.ahg.common.util.HttpUtil;
import name.marz.to.go.ahg.core.AutoGetterHttpClient;
import name.marz.to.go.ahg.core.Parameters;
import name.marz.to.go.ahg.core.executer.AbstractPostExecuter;
import name.marz.to.go.ahg.core.responsehandler.DocumentResponseHandler;

import org.apache.http.NameValuePair;
import org.apache.http.client.ResponseHandler;
import org.jsoup.nodes.Document;

//public class MHBKDealDetailExecuter extends AbstractPostExecuter<Document> {
public class MHBKDealDetailExecuter extends AbstractPostExecuter<Document> {
	private final Document doc;
	private final ResponseHandler<Document> handler;

	public MHBKDealDetailExecuter(URI uri,AutoGetterHttpClient client,Document doc) {
		super(uri, client);
		this.doc = doc;
		this.handler = new DocumentResponseHandler(client.getDefaultCharset());
	}

	@Override
	protected List<NameValuePair> getRequestParameters() {
		Parameters p = HttpUtil.getParametersFromInputTags(doc);
		List<NameValuePair> params = new ArrayList<NameValuePair>();
		params.add(p.getNameValuePair("_LUID"));
		params.add(p.getNameValuePair("POSTKEY"));
		params.add(p.getNameValuePair("_FORMID"));
		params.add(p.getNameValuePair("_TARGETID"));
		params.add(p.getNameValuePair("_TOKEN"));
		params.add(p.getNameValuePair("_SUBINDEX"));
		params.add(p.getNameValuePair("_FRAMEID"));
		return params;
	}

	@Override
	protected ResponseHandler<Document> getResponseHandler() {
		return handler;
	}
}